/*
 * Pratama Nur Wijaya (c) 2013 
 * 
 * Project       : Sound Of Indonesia
 * Filename      : Utils.java
 * Creation Date : Mar 30, 2013 time : 9:26:45 PM
 *
 */

package id.pratama.soundofindonesia;

import org.andengine.opengl.texture.TextureOptions;
import id.pratama.soundofindonesia.config.Apps_Configuration;
import id.pratama.soundofindonesia.config.IApps_Data;
import id.pratama.soundofindonesia.config.IApps_Define;

public class Utils implements IApps_Define, IApps_Data
{

	/*
	 * Method untuk medapatkan nilai ratio untuk koordinat (x,y)
	 */
	public static float getRatio(float nilai)
	{
		float nilai_ratio = 0;
		switch (Apps_Configuration.RATIO_USE)
		{
			case RATIO_WIDTH:
				nilai_ratio = nilai / RATIO_RES_WIDTH * RES_WIDTH;
				Utils.TRACE("Hitung ratio " + nilai + " / " + RATIO_RES_WIDTH
						+ " * " + RES_WIDTH
						+ " nilai ratio : " + nilai_ratio);
				break;
			case RATIO_HEIGHT:
				nilai_ratio = nilai / RATIO_RES_HEIGHT * RES_HEIGHT;
				Utils.TRACE("Hitung ratio " + nilai + " / " + RATIO_RES_HEIGHT
						+ " * " + RES_HEIGHT
						+ " nilai ratio : " + nilai_ratio);
				break;
		}

		return nilai_ratio;
	}

	/*
	 * Method untuk mendapatkan ratio untuk Width
	 */
	public static float getRatioWidth(float nilai)
	{
		return nilai / RATIO_RES_WIDTH * RES_WIDTH;
	}

	/*
	 * Method untuk mendapatkan ratio untuk Height
	 */
	public static float getRatioHeight(float nilai)
	{
		return nilai / RATIO_RES_HEIGHT * RES_HEIGHT;
	}

	/*
	 * Method untuk tracing apps pada masa debugging
	 */
	public static void TRACE(String a)
	{
		if (Apps_Configuration.DEBUG)
		{
			System.out.println(a);
		}
	}

	/*
	 * method untuk Anti Aliasing
	 */
	public static TextureOptions getTextureOptions()
	{
		return Apps_Configuration.AA_ENABLE ? TextureOptions.REPEATING_BILINEAR : TextureOptions.REPEATING_NEAREST;
	}
}
